<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('外派结算列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>搜索内容：</label>
                                <input type="text" name="title" placeholder="标题/备注"/>
                            </li>
                            <li>
                                <label>客户：</label>
                                <select name="customerId" class="selectpicker" th:with="type=${@customDictService.selectDictCustomer()}">
                                    <option value="">请选择</option>
                                    <option th:each="dict : ${type}" th:text="${dict.title}" th:value="${dict.id}"></option>
                                </select>
                            </li>
                            <li>
                                <label>结算完成：</label>
                                <select name="settleStatus" th:with="type=${@dict.getType('sys_yes_no')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.addTab()" shiro:hasPermission="erp:settle:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="erp:settle:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('erp:settle:edit')}]];
        var removeFlag = [[${@permission.hasPermi('erp:settle:remove')}]];
        var settleStatusDatas = [[${@dict.getType('sys_yes_no')}]];
        var prefix = ctx + "erp/settle";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                sortName: 'id',
                sortOrder: "desc",
                modalName: "外派结算",
                detailView: true,
                onExpandRow : function(index, row, $detail) {
                    initChildTable(index, row, $detail);
                },
                columns: [
                {
                    field: 'id',
                    title: '',
                    visible: false
                },
                {
                    field: 'title',
                    title: '标题'
                },
                {
                    field: 'customerName',
                    title: '客户'
                },
                {
                    field: 'settleStatus',
                    title: '结算完成',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(settleStatusDatas, value);
                    }
                },
                {
                    field: 'invoiceValue',
                    title: '发票金额'
                },
                {
                    field: 'invoiceNumber',
                    title: '发票号'
                },
                {
                    field: 'invoiceDate',
                    title: '开票日期'
                },
                {
                    field: 'amount',
                    title: '结算金额'
                },
                {
                    field: 'payedAmount',
                    title: '已收金额'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.editTab(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        initChildTable = function(index, row, $detail) {
            var childTable = $detail.html('<table style="table-layout:fixed"></table>').find('table');
            $(childTable).bootstrapTable({
                data : row.monthBills,
                columns: [
                    {
                        field: 'projectName',
                        width: '300px',
                        title: '项目名称'
                    },
                    {
                        field: 'personName',
                        title: '姓名'
                    },
                    {
                        field: 'billYear',
                        title: '结算周期',
                        formatter: function(value, row, index) {
                            return value + "年" + row.billMonth + "月";
                        }
                    },
                    {
                        field: 'workFee',
                        title: '工时费用'
                    },
                    {
                        field: 'overtimeFee',
                        title: '加班费'
                    },
                    {
                        field: 'expenseRateFee',
                        title: '报销结算'
                    },
                    {
                        field: 'otherFee',
                        title: '其他费用'
                    },
                    {
                        field: 'expireTime',
                        title: '收款截止期'
                    },
                    {
                        field: 'totalFee',
                        title: '账单费用'
                    },
                    {
                        field: 'amount',
                        title: '结算费用',
                        width: '200px'
                    }
                ]
            });
        };
    </script>
</body>
</html>